package com.yanqu.road.server.manger.config;

import com.yanqu.road.entity.activity.feast.config.ShanHeFeastConfig;
import com.yanqu.road.entity.activity.jieshi.config.JieShiConfig;
import com.yanqu.road.entity.activity.washe.config.WasheConfig;
import com.yanqu.road.entity.activity.xiuxian.config.XiuXianConfig;
import com.yanqu.road.entity.config.goods.*;
import com.yanqu.road.entity.config.system.NormalWeightItem;
import com.yanqu.road.entity.config.travelbook.CardConfig;
import com.yanqu.road.entity.enums.eGoodsType;
import com.yanqu.road.entity.enums.eItemId;
import com.yanqu.road.entity.enums.eMallCategory;
import com.yanqu.road.entity.player.UserCouponItem;
import com.yanqu.road.logic.bussiness.config.GoodsBussiness;
import com.yanqu.road.logic.config.GameConfig;
import com.yanqu.road.server.TempMgr;
import com.yanqu.road.server.manger.DecorationMgr;
import com.yanqu.road.server.manger.MultipleLanguageMgr;
import com.yanqu.road.server.manger.TempCommonMgr;
import com.yanqu.road.server.manger.activity.feast.ShanHeFeastMgr;
import com.yanqu.road.server.manger.activity.jieshi.JieShiMgr;
import com.yanqu.road.server.manger.activity.washe.WasheMgr;
import com.yanqu.road.server.manger.activity.xiuxian.XiuXianMgr;
import com.yanqu.road.server.manger.mammon.MammonMgr;
import com.yanqu.road.server.manger.system.CommonMgr;
import com.yanqu.road.server.manger.system.PlatformGoodsMgr;
import com.yanqu.road.utils.RandomHelper;
import com.yanqu.road.utils.string.StringUtils;

import java.math.BigInteger;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 道具管理类
 */
public class GoodsMgr extends TempMgr {

    private static Map<Integer, GoodsInfo> goodsInfoMap;

    private static Map<Integer, GoodsCompose> goodsComposeMap;

    /**
     * 合成道具，子道具，合成道具需要多少子道具
     */
    private static Map<Integer, Map<Integer, BigInteger>> allGoodsComposeMap;

    private static RandomHelper threadSafeRandom = new RandomHelper();

    private static Map<Integer, List<GoodsInfo>> wineryGoodsInfo = new ConcurrentHashMap<>();

    private static Map<Integer, List<Integer>> mammonDecorationInfo = new ConcurrentHashMap<>();

    /**
     * 缓存的类型内所有道具信息
     */
    private static Map<Integer, List<GoodsInfo>> cacheGoodsInfoListMap = new ConcurrentHashMap<>();

    private static Map<Integer, CardConfig> cardConfigMap = new ConcurrentHashMap<>(); // 旅行册卡牌配置列表

    @Override
    public boolean init() throws Exception {
        return reload();
    }

    @Override
    public boolean stop() {
        return false;
    }

    @Override
    public boolean save() {
        return false;
    }

    @Override
    public boolean reloadConfig() {
        Map<Integer, GoodsInfo> tempGoodsInfoMap = GoodsBussiness.getGoodsInfoMap();
        TempCommonMgr.initGoodsInfoMap(tempGoodsInfoMap);
        goodsInfoMap = tempGoodsInfoMap;
        goodsComposeMap = GoodsBussiness.getGoodsComposeMap();
        allGoodsComposeMap = initGoodsComposeMap();
        Map<Integer,List<Integer>> tempMammonDecorationInfo = new ConcurrentHashMap<>();
        Map<Integer, CardConfig> tmpCardConfigMap = new HashMap<>();

        Map<Integer, List<GoodsInfo>> dataMap = new ConcurrentHashMap<>();
        for (GoodsInfo value : tempGoodsInfoMap.values()) {
            if (value.getType() == eGoodsType.TravelCard.getValue()) {
                CardConfig card = new CardConfig();
                card.setCardId(value.getGoodsId());
                card.setAlbumId(Integer.parseInt(value.getParamStr()));
                card.setQuality(value.getQuality());
                tmpCardConfigMap.put(value.getGoodsId(), card);
            }
            //财神称号抽出来 有用
            int mammonType = MammonMgr.getMammonType(value);
            if (value.getType() != eGoodsType.Winery.getValue() && mammonType <= 0) {
                continue;
            }
            if (value.getType() == eGoodsType.Winery.getValue()) {
                int wineryType = value.getParamList().get(0).intValue();
                if (!dataMap.containsKey(wineryType)) {
                    dataMap.put(wineryType, new ArrayList<>());
                }
                dataMap.get(wineryType).add(value);
            } else if (mammonType > 0) {
                List<Integer> goodsInfos = tempMammonDecorationInfo.computeIfAbsent(mammonType, k -> new ArrayList<>());
                goodsInfos.add(value.getGoodsId());
            }
        }

        wineryGoodsInfo = dataMap;
        mammonDecorationInfo = tempMammonDecorationInfo;
        cardConfigMap = tmpCardConfigMap;

        synchronized (cacheGoodsInfoListMap) {
            cacheGoodsInfoListMap.clear();
        }
        return true;
    }

    @Override
    public boolean reloadData() throws Exception {
        return true;
    }

    public static Map<Integer, List<Integer>> getMammonDecorationInfo() {
        return mammonDecorationInfo;
    }

    public static Map<Integer, GoodsInfo> getGoodsMap() {
        Map<Integer, GoodsInfo> goodsMap = new HashMap<>(goodsInfoMap);
        for (GoodsInfo goodsInfo : PlatformGoodsMgr.getGoodsInfoList()) {
            goodsMap.put(goodsInfo.getGoodsId(), goodsInfo);
        }
        for (GoodsInfo goodsInfo : CommonMgr.getGoodsInfoList()) {
            goodsMap.put(goodsInfo.getGoodsId(), goodsInfo);
        }
        return goodsMap;
    }

    //获取对应类型的所有道具
    public static Map<Integer, GoodsInfo> getGoodsMapByType(int type) {
        Map<Integer, GoodsInfo> goodsMap = new ConcurrentHashMap<>();
        Map<Integer, GoodsInfo> allGoodsMap = getGoodsMap();
        for (GoodsInfo good : allGoodsMap.values()) {
            if (good.getType() == type) {
                goodsMap.put(good.getGoodsId(), good);
            }
        }
        return goodsMap;
    }

    /**
     * 获取指定类型的道具配置，并且id从小到大排序
     *
     * @param type
     * @return
     */
    public static List<GoodsInfo> getGoodsListByType(int type) {
        if (cacheGoodsInfoListMap.containsKey(type)) {
            return cacheGoodsInfoListMap.get(type);
        } else {
            synchronized (cacheGoodsInfoListMap) {
                if (cacheGoodsInfoListMap.containsKey(type)) {
                    return cacheGoodsInfoListMap.get(type);
                }
                List<GoodsInfo> list = new ArrayList<>();
                Map<Integer, GoodsInfo> allGoodsMap = getGoodsMap();
                for (GoodsInfo good : allGoodsMap.values()) {
                    if (good.getType() == type) {
                        list.add(good);
                    }
                }
                list.sort(Comparator.comparingInt(GoodsInfo::getGoodsId));
                cacheGoodsInfoListMap.put(type, list);
            }
        }
        return cacheGoodsInfoListMap.get(type);
    }


    public static GoodsInfo getGoodsById(int goodsId) {
        GoodsInfo goodsInfo = CommonMgr.getGoodsInfo(goodsId);
        if (null == goodsInfo) {
            goodsInfo = PlatformGoodsMgr.getGoodsInfo(goodsId);
            if (null == goodsInfo) {
                goodsInfo = goodsInfoMap.get(goodsId);
            }
        }
        return goodsInfo;
    }

    public static Map<Integer, GoodsInfo> getGoodsInfoMap() {
        return goodsInfoMap;
    }

    public static GoodsCompose getGoodsCompose(int goodsId) {
        return goodsComposeMap.get(goodsId);
    }

    /**
     * 获取道具合成数量
     *
     * @param goodsId
     * @param childGoodsId
     * @return
     */
    public static BigInteger getGoodsComposeCount(int goodsId, int childGoodsId) {
        Map<Integer, BigInteger> tempMap = allGoodsComposeMap.get(goodsId);
        if (null != tempMap) {
            return tempMap.get(childGoodsId);
        }
        return null;
    }

    /**
     * 初始化道具合成数量
     *
     * @return
     */
    private static Map<Integer, Map<Integer, BigInteger>> initGoodsComposeMap() {
        Map<Integer, Map<Integer, BigInteger>> dataMap = new ConcurrentHashMap<>();
        for (GoodsCompose goodsCompose : goodsComposeMap.values()) {
            Map<Integer, BigInteger> tempDataMap = dataMap.get(goodsCompose.getGoodsId());
            if (null == tempDataMap) {
                tempDataMap = new ConcurrentHashMap<>();
                dataMap.put(goodsCompose.getGoodsId(), tempDataMap);
            }
            int goodsId = 0;
            BigInteger count = BigInteger.ZERO;
            for (Map.Entry<Integer, BigInteger> dataEntry : goodsCompose.getConsume().getGoods().entrySet()) {
                goodsId = dataEntry.getKey();
                count = dataEntry.getValue();
            }
            tempDataMap.put(goodsId, count);
        }
        Map<Integer, Map<Integer, BigInteger>> resultMap = new ConcurrentHashMap<>();
        for (Map.Entry<Integer, Map<Integer, BigInteger>> dataEntry : dataMap.entrySet()) {
            Map<Integer, BigInteger> inResultMap = new ConcurrentHashMap<>();
            resultMap.put(dataEntry.getKey(), inResultMap);
            for (Map.Entry<Integer, BigInteger> tempEntry : dataEntry.getValue().entrySet()) {
                setInMap(inResultMap, dataMap, tempEntry.getKey(), tempEntry.getValue());
            }
        }
        return resultMap;
    }

    private static void setInMap(Map<Integer, BigInteger> resultMap, Map<Integer, Map<Integer, BigInteger>> dataMap, int goodsId, BigInteger count) {
        resultMap.put(goodsId, count);
        Map<Integer, BigInteger> tempMap = dataMap.get(goodsId);
        if (null != tempMap) {
            for (Map.Entry<Integer, BigInteger> inEntry : tempMap.entrySet()) {
                setInMap(resultMap, dataMap, inEntry.getKey(), count.multiply(inEntry.getValue()));
            }
        }
    }

    public static BigInteger getAddRandomValue(GoodsInfo goodsInfo) {
        int randomValue = threadSafeRandom.next(0, goodsInfo.getTotalWeight());
        int tempValue = 0;
        for (NormalWeightItem weightItem : goodsInfo.getWeightItemList()) {
            tempValue += weightItem.getWeight();
            if (tempValue >= randomValue) {
                return weightItem.getValue();
            }
        }
        return BigInteger.ZERO;
    }

    /**
     * 是否门客
     */
    public static boolean isPatronsGoods(int goodsId) {
        return goodsId >= 102000 && goodsId <= 102999;
    }

    /**
     * 是否美女
     */
    public static boolean isBeautyGoods(int goodsId) {
        return goodsId >= 103000 && goodsId <= 103999;
    }

    /**
     * 是否坐骑
     */
    public static boolean isPassTransportGoods(int goodsId) {
        return goodsId >= 108000 && goodsId <= 108999;
    }

    /**
     * 是否珍兽
     */
    public static boolean isVehicleGoods(int goodsId) {
        return goodsId >= 104000 && goodsId <= 104999;
    }

    /**
     * 是否
     */
    public static boolean isPassRoadTransport(int goodsId) {
        return goodsId >= 108000 && goodsId <= 108999;
    }

    /**
     * 是否饰品
     */
    public static boolean isDecorationGoods(int goodsId) {
        return goodsId >= 106000 && goodsId <= 106999;
    }

    /**
     * 是否蛐蛐
     */
    public static boolean isCricketGoods(int goodsId) {
        GoodsInfo goodsInfo = getGoodsById(goodsId);
        if (goodsInfo == null) {
            return false;
        }
        return goodsInfo.getType() == eGoodsType.Cricket.getValue();
    }

    /**
     * 是否美女亲密度道具
     */
    public static boolean isBeautyIntimacy(GoodsInfo goodsInfo) {
        if (null == goodsInfo) {
            return false;
        }
        return goodsInfo.getType() == eGoodsType.BeautyIntimacy.getValue();
    }

    /**
     * 是否美女魅力值道具道具
     */
    public static boolean isBeautyGlamour(GoodsInfo goodsInfo) {
        if (null == goodsInfo) {
            return false;
        }
        return goodsInfo.getType() == eGoodsType.BeautyGlamour.getValue();
    }

    /**
     * 是否子嗣席位培养次数恢复道具
     */
    public static boolean isChildSiteTrainTimesRecover(GoodsInfo goodsInfo) {
        if (null == goodsInfo) {
            return false;
        }
        return goodsInfo.getType() == eGoodsType.ChildSiteTrainTimesRecover.getValue();
    }

    /**
     * 是否子商战挑战券
     */
    public static boolean isTradeWarChallenge(int goodsId) {
        GoodsInfo goodsInfo = getGoodsById(goodsId);
        if (null == goodsInfo) {
            return false;
        }
        return goodsInfo.getType() == eGoodsType.TradeWarChallenge.getValue();
    }

    /**
     * 是否道具包
     */
    public static boolean isGoodsBag(int goodsId) {
        GoodsInfo goodsInfo = getGoodsById(goodsId);
        if (null == goodsInfo) {
            return false;
        }
        return goodsInfo.getType() == eGoodsType.GoodsBag.getValue();
    }

    public static boolean isUnionFlag(int goodsId) {
        GoodsInfo goods = getGoodsById(goodsId);
        if (goods == null || goods.getType() != eGoodsType.UnionFlag.getValue()) {
            return false;
        }
        return true;
    }

    public static boolean isUnionFlagParts(int goodsId) {
        GoodsInfo goods = getGoodsById(goodsId);
        if (goods == null || goods.getType() != eGoodsType.UnionFlagParts.getValue()) {
            return false;
        }
        return true;
    }

    /**
     * 是否是荣誉点积分
     */
    public static boolean isHonorScore(int goodsId){
        GoodsInfo goods = getGoodsById(goodsId);
        if (goods == null || goods.getType() != eGoodsType.UnionHonorScore.getValue()) {
            return false;
        }
        return true;
    }
    /**
     * 是否是五熊真棒的技能道具
     */
    public static boolean isFiveHeroAddItem(int goodsId){
        GoodsInfo goods = getGoodsById(goodsId);
        if (goods == null || goods.getType() != eGoodsType.FiveHeroAddItem.getValue()) {
            return false;
        }
        return true;
    }

    /**
     * 获取会旗的持续时间
     *
     * @param flagId
     * @return 返回毫秒
     */
    public static long getUnionFlagDurationTime(int flagId) {
        GoodsInfo goods = getGoodsById(flagId);
        if (goods == null || goods.getType() != eGoodsType.UnionFlag.getValue()) {
            return 0;
        }
        return goods.getParamList().get(0).longValue() * 60 * 1000;
    }

    /**
     * 是否商战通缉道具
     */
    public static boolean isTradeWarWanted(int goodsId) {
        GoodsInfo goodsInfo = getGoodsById(goodsId);
        if (null == goodsInfo) {
            return false;
        }
        return goodsId == GameConfig.TRADE_WAR_WANTED_ITEM_ID || goodsId == eItemId.TRADE_WAR_SENIOR_WANTED_GOODS.getValue();
    }

    public static int getLTPMainRoleSkinGoodId(int goodsId) {
        GoodsInfo goodsInfo = getGoodsById(goodsId);
        if (goodsInfo == null) {
            return 0;
        }
        for (GoodsInfo info : goodsInfoMap.values()) {
            if (info.getType() == eGoodsType.Skin.getValue() && !info.getExtendParam().equals("0")) {
                String[] goodsIdArr = info.getExtendParam().split(";");
                for (String goodsIdStr : goodsIdArr) {
                    if (Integer.parseInt(goodsIdStr) == goodsId) {
                        return info.getGoodsId();
                    }
                }
            }
        }
        return 0;
    }
    //获取玩家最高称号阶级
    public static int getUserDecorationClass(List<Integer> userDecorationList) {
        int userDecorationClass = -1;    //称号越高，阶级越大
        for (int decorationId : userDecorationList) {
            GoodsInfo goodsInfo = GoodsMgr.getGoodsById(decorationId);
            if(goodsInfo == null){
                continue;
            }
            List<Integer> list = StringUtils.stringToIntegerList(goodsInfo.getExtendParam(), "\\|");
            if(list.size() < 6){
                continue;
            }
            int tempClass = list.get(4);
            if (tempClass > userDecorationClass) {
                userDecorationClass = tempClass;
            }
        }
        return userDecorationClass;
    }

    //获取玩家最高称号阶级
    public static int getUserDecorationClass(String userDecoration) {
        if(StringUtils.isNullOrEmpty(userDecoration)){
            return -1;
        }
        return getUserDecorationClass(StringUtils.stringToIntegerList(userDecoration, DecorationMgr.SPLIT_SEPARATOR));
    }


    //获取玩家最高称号
    public static int getUserDecorationMaxLevel(List<Integer> userDecorationList) {
        int userDecorationClass = -1;    //称号越高，阶级越大
        int curDecorationId = 0;
        for (int decorationId : userDecorationList) {
            GoodsInfo goodsInfo = GoodsMgr.getGoodsById(decorationId);
            if(goodsInfo == null){
                continue;
            }
            List<Integer> list = StringUtils.stringToIntegerList(goodsInfo.getExtendParam(), "\\|");
            if(list.size() < 6){
                continue;
            }
            int tempClass = list.get(4);
            if (tempClass > userDecorationClass) {
                userDecorationClass = tempClass;
                curDecorationId = decorationId;
            }
        }
        return curDecorationId;
    }


    /**
     * 是否凭证道具
     */
    public static boolean isAbleGoods(int goodsId) {
        GoodsInfo goodsInfo = getGoodsById(goodsId);
        if (goodsInfo != null && goodsInfo.getType() == eGoodsType.AbleItem.getValue()) {
            return true;
        }
        return false;
    }

    /**
     * 是否为瓦舍棋盘
     */
    public static boolean isWaSheBoard(int goodsId) {
        GoodsInfo goodsInfo = getGoodsById(goodsId);
        if (goodsInfo != null && goodsInfo.getType() == eGoodsType.WaSheBoard.getValue()) {
            return true;
        }
        return false;
    }

    /**
     * 是否为瓦舍结算动画
     */
    public static boolean isWaSheSettleAnimation(int goodsId) {
        GoodsInfo goodsInfo = getGoodsById(goodsId);
        if (goodsInfo != null && goodsInfo.getType() == eGoodsType.WaSheSettlementAnimation.getValue()) {
            return true;
        }
        return false;
    }

    /**
     * 是否为瓦舍消除特效
     */
    public static boolean isWaSheEliminateEffect(int goodsId) {
        GoodsInfo goodsInfo = getGoodsById(goodsId);
        if (goodsInfo != null && goodsInfo.getType() == eGoodsType.WaSheEliminateEffect.getValue()) {
            return true;
        }
        return false;
    }


    /**
     * 是否瓦舍夺魁卡片
     */
    public static boolean isWasheCard(int goodsId) {
        GoodsInfo goodsInfo = getGoodsById(goodsId);
        if (goodsInfo != null && goodsInfo.getType() == eGoodsType.WasheCard.getValue()) {
            return true;
        }
        return false;
    }

    /**
     * 是否瓦舍夺魁盘面技能
     */
    public static boolean isWasheSkill(int goodsId) {
        GoodsInfo goodsInfo = getGoodsById(goodsId);
        if (goodsInfo != null && goodsInfo.getType() == eGoodsType.WasheSkill.getValue()) {
            return true;
        }
        return false;
    }

    public static boolean isRealReward(int goodsId) {
        GoodsInfo goodsInfo = getGoodsById(goodsId);
        if (goodsInfo != null && goodsInfo.getType() == eGoodsType.RealReward.getValue()) {
            return true;
        }
        return false;
    }

    public static boolean isSpecialSkinBox(int goodsId) {
        GoodsInfo goodsInfo = getGoodsById(goodsId);
        if (goodsInfo != null && goodsInfo.getType() == eGoodsType.SpecialSkinBox.getValue()) {
            return true;
        }
        return false;
    }

    public static boolean isActivityRealReward(int goodsId) {
        GoodsInfo goodsInfo = getGoodsById(goodsId);
        if (goodsInfo != null && goodsInfo.getType() == eGoodsType.ActivityRealReward.getValue()) {
            return true;
        }
        return false;
    }

    //定制烟花道具id范围
    public static boolean isSpFireGood(int goodsId){
        if(goodsId >= 123106 && goodsId <= 123113){
            return true;
        }
        return false;
    }

    /**
     * 是否勋章解锁道具ID
     */
    public static boolean isBadgeUnlockItem(int goodsId) {
        GoodsInfo goodsInfo = getGoodsById(goodsId);
        if (goodsInfo != null && goodsInfo.getType() == eGoodsType.BadgeUnlockItem.getValue()) {
            return true;
        }
        return false;
    }

    /**
     * 是否凡人道具
     */
    public static boolean isXiuXianGoods(int goodsId) {
        GoodsInfo goodsInfo = getGoodsById(goodsId);
        if (goodsInfo != null && goodsInfo.getType() == eGoodsType.XiuXian.getValue()) {
            return true;
        }
        return false;
    }

    /**
     * 山河乐宴道具
     */
    public static boolean isShanHeFeastGoods(int goodsId) {
        GoodsInfo goodsInfo = getGoodsById(goodsId);
        if (goodsInfo != null && goodsInfo.getType() == eGoodsType.Feast.getValue()) {
            return true;
        }
        return false;
    }

    /**
     * 是否区域对决道具
     */
    public static boolean isAreaFightMedalGoods(int goodsId) {
        GoodsInfo goodsInfo = getGoodsById(goodsId);
        if (goodsInfo != null && goodsInfo.getType() == eGoodsType.AreaFightMedal.getValue()) {
            return true;
        }
        return false;
    }

    public static boolean isDaoMuJiBaiShuLiangGoods(int goodsId){
        return goodsId == eItemId.DaoMuJiBaiShuLiangItem.getValue();
    }

    /**
     * 是否凡人机缘点道具
     */
    public static boolean isXiuXianJiYuanDian(int goodsId) {
        XiuXianConfig config = XiuXianMgr.getConfig();
        if (config == null) {
            return false;
        }
        if (goodsId == config.getXIUXIAN_JIYUANDIAN_ITEM_ID()) {
            return true;
        }
        return false;
    }

    /**
     * 是否山河乐宴灵感点道具
     */
    public static boolean isShanHeFeastLingGanDian(int goodsId) {
        ShanHeFeastConfig config = ShanHeFeastMgr.getConfig();
        if (config == null) {
            return false;
        }
        if (goodsId == config.getFEAST_ROLL_ITEM_ID()) {
            return true;
        }
        return false;
    }

    /**
     * 是否灯火街市交子道具
     */
    public static boolean isJieShiJiaoZi(int goodsId) {
        JieShiConfig config = JieShiMgr.getConfig();
        if (config == null) {
            return false;
        }
        if (goodsId == config.getLIGHTMARKET_MONEY_ITEM_ID()) {
            return true;
        }
        return false;
    }

    /**
     * 是否掌柜夺魁锦标赛积分道具
     */
    public static boolean isWasheJinBiaoScoreItemId(int goodsId) {
        WasheConfig config = WasheMgr.getWasheConfig();
        if (config == null) {
            return false;
        }
        if (goodsId == config.getJinBiaoScoreItemId()) {
            return true;
        }
        return false;
    }

    /**
     * 是否蛐蛐竞技场勋章经验
     */
    public static boolean isCricketCourtBadgeExp(int goodsId) {
        return goodsId == 101066;
    }

    /**
     * 是否蛐蛐竞技场战令经验
     */
    public static boolean isCricketCourtTokenExp(int goodsId) {
        return goodsId == 101853;
    }

    public static GoodsInfo getWineryGoodsInfo(int wineryType, int quality) {
        List<GoodsInfo> list = GoodsMgr.wineryGoodsInfo.get(wineryType);
        if (list.isEmpty()) {
            return null;
        }

        return list.stream().filter(v -> v.getQuality() == quality).findFirst().orElse(null);
    }

    public static boolean isTombDollItem(int goodsId) {
        GoodsInfo goodsInfo = getGoodsById(goodsId);
        if (goodsInfo != null && goodsInfo.getType() == eGoodsType.TombDoll.getValue()) {
            return true;
        }
        return false;
    }

    /**
    * 描述：是否优惠券道具
    * 作者：zrq
    * 时间：2023/4/18
    * 参数：

    * 返回值：
    **/
    public static boolean isCouponItem(int goodsId){
        GoodsInfo goodsInfo = getGoodsById(goodsId);
        if (goodsInfo != null && goodsInfo.getType() == eGoodsType.CouponItem.getValue()) {
            return true;
        }
        return false;
    }

    /**
     * 是否美团无门槛券
     */
    public static boolean isMeiTuanQuan(int goodsId) {
        GoodsInfo goodsInfo = getGoodsById(goodsId);
        if (goodsInfo != null && goodsInfo.getType() == eGoodsType.MeiTuanQuan.getValue()) {
            return true;
        }
        return false;
    }

    /**
    * 描述：商品是否可以使用优惠券
    * 作者：zrq
    * 时间：2023/4/18
    * 参数：

    * 返回值：
    **/
    public static boolean isMallCanUseCouponItem(MallInfo mallInfo, int couponGoodsId){
        if(null == mallInfo){
            return false;
        }
        if(mallInfo.getRechargeId() <= 0){
            return false;
        }
        long price = MallRechargeConfigMgr.getPrice(mallInfo);
//        int price = Integer.parseInt(mallInfo.getPrice());      //商品价格档位
        GoodsInfo goodsInfo = getGoodsById(couponGoodsId);
        if(null == goodsInfo){
            return false;
        }
        int param2 = goodsInfo.getParamList().get(1).intValue();     //可使用价格档位
        if(price == param2){
            return true;
        }
        if (mallInfo.getCategory() == eMallCategory.TongBaoRecharge.getValue()) {   //通宝充值不给用
            return false;
        }
        return false;
    }

    /**
    * 描述：获取优惠券道具
    * 作者：zrq
    * 时间：2023/4/20
    * 参数：

    * 返回值：
    **/
    public static List<GoodsInfo> getCouponGoodsList(MallInfo mallInfo){
        List<GoodsInfo> dataList = new ArrayList<>();
        if(null == mallInfo){
            return dataList;
        }
        if(mallInfo.getRechargeId() <= 0){
            return dataList;
        }
        long price = MallRechargeConfigMgr.getPrice(mallInfo);
//        int price = Integer.parseInt(mallInfo.getPrice());      //商品价格档位
        for(GoodsInfo goodsInfo : goodsInfoMap.values()){
            if(goodsInfo.getType() != eGoodsType.CouponItem.getValue()){
                continue;
            }
            int param2 = goodsInfo.getParamList().get(1).intValue();     //可使用价格档位
            if(price == param2){
                dataList.add(goodsInfo);
            }
        }
        dataList.sort(Comparator.comparing(o -> o.getParamList().get(0)));
        return dataList;
    }

    public static List<GoodsInfo> getCouponGoodsList(){
        List<GoodsInfo> dataList = new ArrayList<>();
        for(GoodsInfo goodsInfo : goodsInfoMap.values()){
            if(goodsInfo.getType() == eGoodsType.CouponItem.getValue()){
                dataList.add(goodsInfo);
            }
        }
        dataList.sort(Comparator.comparing(o -> o.getParamList().get(0)));
        return dataList;
    }

    /**
    * 描述：获取本地道具名称
    * 作者：zrq
    * 时间：2023/4/26
    * 参数：

    * 返回值：
    **/
    public static String getLocalGoodsName(int goodsId, String language){
        String goodsName = "";
        GoodsInfo goodsInfo = getGoodsById(goodsId);
        if(null != goodsInfo){
            goodsName = MultipleLanguageMgr.getContent(goodsInfo.getGoodsName(), language);
        }
        return goodsName;
    }

    /**
    * 描述：根据手机平台判断是不是可用的代金券
    * 作者：zrq
    * 时间：2023/8/11
    * 参数：

    * 返回值：
    **/
    public static boolean canUseCoupon(UserCouponItem userCouponItem, int phonePlatform){
        if(null == userCouponItem){
            return false;
        }
        GoodsInfo goodsInfo = getGoodsById(userCouponItem.getGoodsId());
        if(null == goodsInfo){
            return false;
        }
        List<Integer> phonePlatformList = StringUtils.stringToIntegerList(goodsInfo.getExtendParam(), ";");
        return phonePlatformList.contains(phonePlatform);
    }

    /**
     * 是否魂骨
     */
    public static boolean isVehicleBone(int goodsId) {
        GoodsInfo goodsInfo = getGoodsById(goodsId);
        if (goodsInfo == null) {
            return false;
        }
        return goodsInfo.getType() == eGoodsType.VehicleBone.getValue();
    }

    /**
     * 判断一个道具是否是某个类型
     * @param goodsId
     * @param goodType
     * @return
     */

    public static boolean goodIsThisType(int goodsId,int goodType) {
        GoodsInfo goodsInfo = getGoodsById(goodsId);
        if (goodsInfo == null) {
            return false;
        }
        return goodsInfo.getType() == goodType;
    }

    public static Map<Integer, CardConfig> getCardConfigMap() {
        return cardConfigMap;
    }

    /**
     * 是否为旅行册卡牌
     *
     * @param goodsId 道具ID
     * @return boolean
     */
    public static boolean isTravelCard(int goodsId) {
        return cardConfigMap.containsKey(goodsId);
    }
}
